package openase.audiosearch.comm.request.decoder;

import java.nio.ByteBuffer;

import openase.audiosearch.comm.StringFormatUtils;
import openase.audiosearch.comm.request.AudioRegistration;


public class AudioRegistrationRequestDecoder implements RequestDecoder<AudioRegistration> {

	public AudioRegistration decode(ByteBuffer inputBuffer) {
		int sz;

		sz = inputBuffer.getInt();
		byte[] nameBytes = new byte[sz];
		inputBuffer.get(nameBytes);
		String name = StringFormatUtils.getUtf8(nameBytes);

		sz = inputBuffer.getInt();
		byte[] audioBytes = new byte[sz];
		inputBuffer.get(audioBytes);

		return new AudioRegistration(name, audioBytes);
	}
}
